import { type HttpHandler, HttpResponse, http } from 'msw'

export const handlers: HttpHandler[] = [
  http.get('/mock/system/user/getInfo', async () => {
    return HttpResponse.json({
      code: 200,
      msg: '操作成功',
      data: {
        permissions: ['*:*:*'],
        roles: ['admin'],
        user: {
          searchValue: null,
          createBy: 'admin',
          createTime: '2023-01-31 09:44:47',
          updateBy: null,
          updateTime: null,
          userId: 1,
          deptId: 103,
          userName: 'admin',
          nickName: '疯狂的狮子Li',
          userType: 'sys_user',
          email: 'crazyLionLi@163.com',
          phonenumber: '15888888888',
          sex: '1',
          avatar: '',
          status: '0',
          delFlag: '0',
          loginIp: '127.0.0.1',
          loginDate: '2023-01-31 09:44:47',
          remark: '管理员',
          dept: {
            searchValue: null,
            createBy: null,
            createTime: null,
            updateBy: null,
            updateTime: null,
            parentName: null,
            parentId: 101,
            children: [],
            deptId: 103,
            deptName: '研发部门',
            orderNum: 1,
            leader: '若依',
            phone: null,
            email: null,
            status: '0',
            delFlag: null,
            ancestors: '0,100,101',
          },
          roles: [
            {
              searchValue: null,
              createBy: null,
              createTime: null,
              updateBy: null,
              updateTime: null,
              roleId: 1,
              roleName: '超级管理员',
              roleKey: 'admin',
              roleSort: 1,
              dataScope: '1',
              menuCheckStrictly: null,
              deptCheckStrictly: null,
              status: '0',
              delFlag: null,
              remark: null,
              flag: false,
              menuIds: null,
              deptIds: null,
              permissions: null,
              admin: true,
            },
          ],
          roleIds: null,
          postIds: null,
          roleId: null,
          admin: true,
        },
      },
    })
  }),
  http.get('/mock/system/dict/type/optionselect', async () => {
    return HttpResponse.json({
      code: 200,
      msg: '操作成功',
      data: [],
    })
  }),
  http.get('mock/system/dict/data/all', async () => {
    return HttpResponse.json({
      code: 200,
      msg: '操作成功',
      data: [],
    })
  }),
  http.get('mock/system/user/deptTree', async () => {
    return HttpResponse.json({
      code: 200,
      msg: '操作成功',
      data: [],
    })
  }),
  http.get('mock/system/user/list', async () => {
    return HttpResponse.json({
      code: 200,
      msg: '操作成功',
      rows: [],
      total: 0,
    })
  }),
  http.get('/mock/system/menu/getRouters/0,0', async () => {
    return HttpResponse.json({
      code: 200,
      msg: '操作成功',
      data: [
        {
          name: 'Tool',
          path: '/tool',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: {
            title: '系统工具',
            icon: 'tool',
            noCache: false,
            link: null,
          },
          children: [
            {
              name: 'Build',
              path: 'build',
              hidden: false,
              component: 'tool/build/index',
              meta: {
                title: '表单构建',
                icon: 'build',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Gen',
              path: 'gen',
              hidden: false,
              component: 'tool/gen/index',
              meta: {
                title: '代码生成',
                icon: 'code',
                noCache: false,
                link: null,
              },
            },
          ],
        },
        {
          name: 'System',
          path: '/system',
          hidden: false,
          redirect: 'noRedirect',
          component: 'Layout',
          alwaysShow: true,
          meta: {
            title: '系统管理',
            icon: 'dashboard',
            noCache: false,
            link: null,
          },
          children: [
            {
              name: 'User',
              path: 'user',
              hidden: false,
              component: 'system/user/index',
              meta: {
                title: '用户管理',
                icon: 'user',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Role',
              path: 'role',
              hidden: false,
              component: 'system/role/index',
              meta: {
                title: '角色管理',
                icon: 'peoples',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Menu',
              path: 'menu',
              hidden: false,
              component: 'system/menu/index',
              meta: {
                title: '菜单管理',
                icon: 'tree-table',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Dept',
              path: 'dept',
              hidden: false,
              component: 'system/dept/index',
              meta: {
                title: '部门管理',
                icon: 'tree',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Post',
              path: 'post',
              hidden: false,
              component: 'system/post/index',
              meta: {
                title: '岗位管理',
                icon: 'post',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Dict',
              path: 'dict',
              hidden: false,
              component: 'system/dict/index',
              meta: {
                title: '字典管理',
                icon: 'dict',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Config',
              path: 'config',
              hidden: false,
              component: 'system/config/index',
              meta: {
                title: '参数设置',
                icon: 'edit',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Notice',
              path: 'notice',
              hidden: false,
              component: 'system/notice/index',
              meta: {
                title: '通知公告',
                icon: 'message',
                noCache: false,
                link: null,
              },
            },
            {
              name: 'Log',
              path: 'log',
              hidden: false,
              redirect: 'noRedirect',
              component: 'ParentView',
              alwaysShow: true,
              meta: {
                title: '日志管理',
                icon: 'log',
                noCache: false,
                link: null,
              },
              children: [
                {
                  name: 'Operlog',
                  path: 'operlog',
                  hidden: false,
                  component: 'system/operlog/index',
                  meta: {
                    title: '操作日志',
                    icon: 'form',
                    noCache: false,
                    link: null,
                  },
                },
                {
                  name: 'Logininfor',
                  path: 'logininfor',
                  hidden: false,
                  component: 'system/logininfor/index',
                  meta: {
                    title: '登录日志',
                    icon: 'logininfor',
                    noCache: false,
                    link: null,
                  },
                },
              ],
            },
            {
              name: 'Oss',
              path: 'oss',
              hidden: false,
              component: 'system/oss/index',
              meta: {
                title: '文件管理',
                icon: 'upload',
                noCache: false,
                link: null,
              },
            },
          ],
        },
      ],
    })
  }),
]
